Shader "Custom/NewSurfaceShader"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
        _modNum ("条纹数量", Range(2,30)) = 10.0
        _uRatio ("占比", Range(0,1)) = 0.3

    }
    SubShader
    {
        Tags { "RenderType"="transparent"}
        LOD 200

        CGPROGRAM
        // Physically based Standard lighting model, and enable shadows on all light types
        #pragma surface surf Standard fullforwardshadows

        // Use shader model 3.0 target, to get nicer looking lighting
        #pragma target 3.0

        sampler2D _MainTex;

        struct Input
        {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        half _modNum;
        half _uRatio;
        fixed4 _Color;

        // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
        // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
        // #pragma instancing_options assumeuniformscaling
        UNITY_INSTANCING_BUFFER_START(Props)
            // put more per-instance properties here
        UNITY_INSTANCING_BUFFER_END(Props)

        // floor,ceil和 frac
        void surf (Input IN, inout SurfaceOutputStandard o)
        {
       
 // https://learn.u3d.cn/tutorial/mathematical-visualization-art?chapterId=63f44580fe40ab001f923ced#63f44a029e22c9001fb093a4
     // 计算强度，取余 mod改成fmod。mix改成lerp
    //  ceil变成颜色块渐变
    // float strength = IN.uv_MainTex.x;
    // float strength = ceil(IN.uv_MainTex.x*5)/5;
    // float strength = floor(IN.uv_MainTex.x*5)/5;
    // 直接取小数 ，变成5个正常的0-1之间，重复图案的uv动画，相当于mod
    // float strength = frac(IN.uv_MainTex.x*5)/5;
    //  strength *= frac(IN.uv_MainTex.y*5)/5;
    // float strength = fmod(IN.uv_MainTex.x,0.25)*4;
    // strength *= fmod(IN.uv_MainTex.y,0.25)*4;
    // saturate(x) 讲指定值固定在 0-1 ，相当于clamp(x,0,1)
    // clamp(x,min,max),将指定值固定在 最大 最小值
    // strength = saturate(strength);
    // strength = clamp(strength,0.3,0.7);
    // step(y,x),y小于x就是0，不然是1
    float strength= sqrt(pow(IN.uv_MainTex.y*2-1,2)+pow(IN.uv_MainTex.x*2-1,2));//根号 欧式距离，干嘛不用length
    // float strength = distance(IN.uv_MainTex, float2(0.5, 0.5));
    // strength = step(strength,0.5);
    // strength = step(strength,0.5);
    // sign(x) x小于0是-1，等于0是0，大于0是1
    // lerp(x,y,z) 0<=z<=1，z在0和1之间，结果是x和y之间，相当于mix
    // fixed4 fixColor1  = fixed4(1,1,0,1);
    // fixed4 fixColor2  = fixed4(0,0,1,1);
    // fixed4 finalColor =lerp(fixColor1,fixColor2,strength);
    // strength =lerp(0.1,0.5,strength);
    // smoothstep(x,y,z) 0<=z<=1，x<=z<=y，z在x和y之间，结果是0-1之间，相当于lerp
    // strength = smoothstep(0.4,0.5,strength);
    strength = smoothstep(0.3,0.4,strength)-smoothstep(0.4,0.5,strength);//小圆减去 大圆颜色值，实现完美圆环
   

    // 设置表面颜色
    // o.Albedo = finalColor;
    o.Albedo = fixed3(strength, strength, strength)*_Color;
    o.Alpha = 1.0;
        }
        ENDCG
    }
    FallBack "Diffuse"
}
